package suse.hotel.admin.admin.Mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import suse.hotel.admin.admin.DTO.OrderDTO;
import suse.hotel.admin.admin.Entity.Order;

import java.util.List;

@Repository
@Mapper
public interface OrderMapper {
    @Select("select * from hotel_order,hotel_message where hotel_message.hotel_id=hotel_order.hotel_id ")
    List<OrderDTO> listOrders();
    @Select("select * from hotel_order,hotel_message where hotel_message.hotel_id=hotel_order.hotel_id and hotel_order.username=#{key}")
    List<OrderDTO> searchOrder(String key);
    @Delete("delete from hotel_order where order_id=#{id}")
    int delOrder(int id);
    @Update("UPDATE hotel_order SET  phone = #{phone},username = #{username}, email = #{email} WHERE order_id = #{orderId}")
    int editOrder(Order order);
}
